package com.ruoyi.crm.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.crm.domain.CrmOrderRegisterDetails;
import com.ruoyi.crm.service.ICrmOrderRegisterDetailsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 项目预算成本费用支出Controller
 *
 * @author yanwenliang
 * @date 2024-11-09
 */
@RestController
@RequestMapping("/crm/orderRegisterDetails")
public class CrmOrderRegisterDetailsController extends BaseController
{
    @Autowired
    private ICrmOrderRegisterDetailsService crmOrderRegisterDetailsService;

    /**
     * 查询项目预算成本费用支出列表
     */
    // @PreAuthorize("@ss.hasPermi('crm:orderRegisterDetails:list')")
    @GetMapping("/list")
    public TableDataInfo list(CrmOrderRegisterDetails crmOrderRegisterDetails)
    {
        startPage();
        List<CrmOrderRegisterDetails> list = crmOrderRegisterDetailsService.selectCrmOrderRegisterDetailsList(crmOrderRegisterDetails);
        return getDataTable(list);
    }

    /**
     * 导出项目预算成本费用支出列表
     */
    // @PreAuthorize("@ss.hasPermi('crm:orderRegisterDetails:export')")
    @Log(title = "项目预算成本费用支出", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CrmOrderRegisterDetails crmOrderRegisterDetails)
    {
        List<CrmOrderRegisterDetails> list = crmOrderRegisterDetailsService.selectCrmOrderRegisterDetailsList(crmOrderRegisterDetails);
        ExcelUtil<CrmOrderRegisterDetails> util = new ExcelUtil<CrmOrderRegisterDetails>(CrmOrderRegisterDetails.class);
        util.exportExcel(response, list, "项目预算成本费用支出数据");
    }

    /**
     * 获取项目预算成本费用支出详细信息
     */
    // @PreAuthorize("@ss.hasPermi('crm:orderRegisterDetails:query')")
    @GetMapping(value = "/{detailsId}")
    public AjaxResult getInfo(@PathVariable("detailsId") String detailsId)
    {
        return success(crmOrderRegisterDetailsService.selectCrmOrderRegisterDetailsByDetailsId(detailsId));
    }

    /**
     * 新增项目预算成本费用支出
     */
    // @PreAuthorize("@ss.hasPermi('crm:orderRegisterDetails:add')")
    @Log(title = "项目预算成本费用支出", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CrmOrderRegisterDetails crmOrderRegisterDetails)
    {
        return toAjax(crmOrderRegisterDetailsService.insertCrmOrderRegisterDetails(crmOrderRegisterDetails));
    }

    /**
     * 修改项目预算成本费用支出
     */
    // @PreAuthorize("@ss.hasPermi('crm:orderRegisterDetails:edit')")
    @Log(title = "项目预算成本费用支出", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CrmOrderRegisterDetails crmOrderRegisterDetails)
    {
        return toAjax(crmOrderRegisterDetailsService.updateCrmOrderRegisterDetails(crmOrderRegisterDetails));
    }

    /**
     * 删除项目预算成本费用支出
     */
    // @PreAuthorize("@ss.hasPermi('crm:orderRegisterDetails:remove')")
    @Log(title = "项目预算成本费用支出", businessType = BusinessType.DELETE)
	@DeleteMapping("/{detailsIds}")
    public AjaxResult remove(@PathVariable String[] detailsIds)
    {
        return toAjax(crmOrderRegisterDetailsService.deleteCrmOrderRegisterDetailsByDetailsIds(detailsIds));
    }
}
